package com.cskaoyan.gateway.controller.user;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.commons.tool.utils.CookieUtil;
import com.mall.user.dto.CheckAuthRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author：Chunk
 * @Description: 用户登出控制中心
 * @Date Created in 9:33 2021/4/22
 */
@RestController
@RequestMapping("/user")
public class LogoutController {


    @GetMapping("/loginOut")
    public ResponseData logout(HttpServletRequest request, HttpServletResponse response){
        //清除cookie
        Cookie cookie = new Cookie("access_token",null);
        cookie.setMaxAge(0);//设置存活时间，“0”即马上消失
        cookie.setPath("/");
        response.addCookie(cookie);
        return new ResponseUtil<>().setData(null);
    }
}
